
import TipModel from "./TipModel";
import BaseView from "../base/view/BaseView";
import ActionHelper from "../action/ActionHelper";



const { ccclass, property } = cc._decorator;

@ccclass
export default class TipView extends BaseView {

    @property(cc.Label)
    label_des: cc.Label = null;

    @property(cc.Node)
    content: cc.Node = null;

    @property(cc.Button)
    leftButton: cc.Button = null;

    @property(cc.Button)
    rightButton: cc.Button = null;

    @property(cc.Button)
    closeButton: cc.Button = null;


    @property(cc.Label)
    leftDes: cc.Label = null;

    @property(cc.Label)
    rightDes: cc.Label = null;

    protected model: TipModel;

    onLoad() {
        // this.node.scale = 0;
    }

    start() {

        this.label_des.string = '' + this.model.getContent();
        ActionHelper.openView(this.content, 0.2)
        if (this.model.isSingle()) {
            this.leftButton.node.active = false
        } else {
            this.leftDes.string = this.model.getLeft();

        }
        this.rightDes.string = this.model.getRight();


    }


    close() {
        // ActionHelper.closeView(this.content, 0.2, () => {
            super.close();
        // })
    }

    onButtonRightClick() {
        this.close();
        this.model.getFunc()(1);
    }

    onButtonLeftClick() {
        this.close();
        this.model.getFunc()(0);
    }

}
